/**
 * Copyright(c) 2013 Jade Techonologies Co., Ltd.
 *
 * History:
 *   13-4-18 下午6:53 Created by dwzhang
 */
package com.jade.framework.base.criterion.expression;

/**
 * 反转的IN条件。
 *
 * @author dwzhang
 * @version 1.0 13-4-18 下午6:53
 */
public class ReverseInExpression extends AbstractPropertyExpression
{
    protected Object value;
    protected boolean not;

    /**
     * 构造函数.
     *
     * @param entityName 实体名称
     * @param propName   属性名称
     * @param value      取值范围
     */
    public <T> ReverseInExpression(String entityName, String propName, T value)
    {
        super(entityName, propName);
        this.value = value;
    }

    /**
     * 构造函数.
     *
     * @param propName 属性名
     * @param value    取值范围.
     */
    public <T> ReverseInExpression(String propName, T value)
    {
        super(propName);
        this.value = value;
    }

    public Object getValue()
    {
        return value;
    }

    public boolean isNot()
    {
        return not;
    }

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append(value);
        if (not) {
            sb.append(" NOT IN ");
        }
        else {
            sb.append(" IN ");
        }
        sb.append(getFullName());
        return sb.toString();
    }
}
